home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
cdr.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
20KB
|
842 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities SCSI-CDROM-Player ** */
/* ** Copright (C) 1993-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#include "ATUtilities.h"
#include <devices/trackdisk.h>
#include <devices/scsidisk.h>
UBYTE tc[100]=
{
/* 00 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
/* 10 */ 9, 9, 9, 9, 9, 9, 10, 11, 12, 13,
/* 20 */ 14, 15, 16, 17, 18, 19, 19, 19, 19, 19,
/* 30 */ 19, 19, 20, 21, 22, 23, 24, 25, 26, 27,
/* 40 */ 28, 29, 29, 29, 29, 29, 29, 29, 30, 31,
/* 50 */ 32, 33, 34, 35, 36, 37, 38, 39, 39, 39,
/* 60 */ 39, 39, 39, 39, 40, 41, 42, 43, 44, 45,
/* 70 */ 46, 47, 48, 49, 49, 49, 49, 49, 49, 49,
/* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
/* 90 */ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59
};
UBYTE *CDPlayerPort="ATUtilities HiFi-Player";
UBYTE *CDCatalogName="AT:HiFi-System/CDCatalog.dat";
struct CDCatalogEntry
{
UWORD TitleCount;
UBYTE Name[60];
UWORD Address[100];
};
struct CDCatalog
{
UWORD EntryCount;
struct CDCatalogEntry Entry[256];
};
#define LUN 0
#define TOC_SIZE 804
struct TOCHeader
{
WORD Length;
UBYTE FirstTrack;
UBYTE LastTrack;
};
struct TOCData
{
UBYTE reserved1;
UBYTE Flags;
UBYTE TrackNumber;
UBYTE reserved2;
LONG Address;
};
struct DriveInfo
{
UBYTE Peripheral_type;
UBYTE Modifier;
UBYTE Version;
UBYTE Flags1;
UBYTE Additional_length;
UBYTE reserved[2];
UBYTE Flags2;
UBYTE Vendor[8];
UBYTE Product[16];
UBYTE Revision[4];
};
UBYTE startaudio[10]={ 0x48, 0, 0, 0, 0, 1, 0, 99, 99, 0 };
UBYTE stopaudio[6]={ 0x1B, 0, 0, 0, 0, 0 };
UBYTE eject[10]={ 0xc4, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
UBYTE readtoc[10]={ 0x43, 0, 0, 0, 0, 0, 0, TOC_SIZE>>8, TOC_SIZE & 0xFF };
UBYTE driveinfo[6]={ 0x12, 0, 0, 0, 96, 0 };
UBYTE test[10]={0xc6, 0x0a, 0, 0, 0, 0, 0, 0, 0, 0};
UBYTE lock[6]={0x1e, 0, 0, 0, 1, 0};
UBYTE unlock[6]={0x1e, 0, 0, 0, 0, 0 };
struct NewScreen HCScreenDef=
{
0,256-102,640,102,3,
0,1,HIRES,CUSTOMSCREEN,
0,0,0,0
};
UWORD Colors[]={0x97a,0x222,0xddd,0xff5,0xdff,0xe0e,0xf03,0x00f};
struct NewWindow HCWindowDef=
{
0,0,640,102,0,1,
MENUPICK|GADGETUP,BORDERLESS,
0L,0L,0L,0L,0L,
50,50,640,100,
CUSTOMSCREEN
};
struct TextAttr DigitalAttr=
{
"hpcalc.font",
18,
FS_NORMAL,
FPF_DISKFONT
};
UBYTE Vendor[10];
UBYTE Product[18];
UBYTE Revision[6];
UBYTE *CDName,*OldCDName=0xFFFFFFFF;
UBYTE *OldIS=0xFFFFFFFF;
BYTE OldSymbol=-1;
BOOL GetDriveInfo();
VOID OpenAll();
VOID SaveList();
VOID CloseAll();
VOID PlaySymbol();
VOID StopSymbol();
VOID ShowCD();
VOID ShowInfoString();
VOID HiFiControl();
VOID TimerTask();
VOID CheckCD();
VOID FindCD();
VOID EdEntry();
WORD SCSI();
struct Window *HCWindow;
struct Screen *HCScreen;
struct RastPort *HCRPort;
struct ViewPort *HCViewPort;
struct MenuStrip *MenuStrip;
struct TextFont *DigitalFont;
struct IOExtTD *io;
struct Task *MainTask;
struct Task *SubTask;
struct Message *msg;
struct SCSICmd *scsi;
struct Gadget *LockGadget;
struct MsgPort *port,*stop,*reply;
struct TOCHeader *tocheader;
struct TOCData *tocdata;
struct Remember *Remember;
struct CDCatalog *catalog;
LONG dev=-1L;
WORD status=0;
UBYTE FirstTrack;
UBYTE LastTrack;
UBYTE CurrentTrack;
UWORD TrackAddress[100];
UBYTE TrackCount;
UBYTE cdpos=0;
ULONG MClass;
UWORD MCode;
struct Gadget *MGad;
struct IntuiMessage *IMsg;
struct MsgPort *UtilityPort;
struct MsgPort *UserPort;
LONG IDCMPSignal,IDCMPSignalMask;
LONG TimerSignal=-1L,TimerSignalMask;
LONG PortSignal,PortSignalMask;
LONG WaitSignalMask;
BOOL play=FALSE,inserted=FALSE,elock=FALSE;
UBYTE *buffer;
UBYTE *sense;
struct Library *IntuitionBase;
struct Library *GfxBase;
struct Library *DiskfontBase;
struct Library *ATUtilitiesBase;
VOID main(argc,argv)
LONG argc;
UBYTE *argv[];
{
UBYTE str[50];
REGISTER LONG i,j,k;
REGISTER ULONG Signale;
REGISTER BOOL bool;
if(argc!=3)
{
printf("Aufruf: %s [SCSI-Device-Name] [CD-ROM-Unit]\n",argv[0]);
exit(0);
}
OpenAll(argv[1],atol(argv[2]));
bool=FALSE;
while(bool==FALSE)
{
Signale=Wait(WaitSignalMask);
if(Signale & TimerSignalMask)
{
CheckCD();
}
if(Signale & PortSignalMask)
{
i=Received(UtilityPort);
while(i!=0)
{
switch(i)
{
case UTILITY_QUIT:
bool=TRUE;
break;
case 1012:
HiFiControl();
break;
}
i=Received(UtilityPort);
}
}
if((IDCMPSignalMask!=0) && (Signale & IDCMPSignalMask))
{
IMsg=GetMsg(UserPort);
while(IMsg!=NULL)
{
MClass=IMsg->Class;
MCode=IMsg->Code;
MGad=IMsg->IAddress;
ReplyMsg(IMsg);
switch(MClass)
{
case GADGETUP:
k=MGad->GadgetID;
if(k<=40)
{
if(inserted==TRUE)
{
if(k>LastTrack) k=LastTrack;
startaudio[4]=k;
if((SCSI(&startaudio,10,buffer,0L,SCSIF_WRITE))==0)
{
sprintf(&str,"Wiedergabe ab Track #%02ld",k);
ShowInfoString(&str);
}
}
}
else
{
switch(k)
{
case 10000:
if(elock==FALSE) SCSI(&eject,10,buffer,0,SCSIF_WRITE);
break;
case 10001:
SCSI(&stopaudio,6,buffer,0,SCSIF_WRITE);
break;
case 4096:
if(LockGadget->Flags & SELECTED)
{ SCSI(&lock,6,buffer,0,SCSIF_WRITE); elock=TRUE; }
else
{ SCSI(&unlock,6,buffer,0,SCSIF_WRITE); elock=FALSE; }
break;
case 10005:
if(CurrentTrack>FirstTrack) CurrentTrack--; else CurrentTrack=LastTrack;
startaudio[4]=CurrentTrack;
if((SCSI(&startaudio,10,buffer,0L,SCSIF_WRITE))==0)
{
sprintf(&str,"Wiedergabe ab Track #%02ld",CurrentTrack);
ShowInfoString(&str);
}
break;
case 10006:
if(CurrentTrack<LastTrack) CurrentTrack++; else CurrentTrack=FirstTrack;
startaudio[4]=CurrentTrack;
if((SCSI(&startaudio,10,buffer,0L,SCSIF_WRITE))==0)
{
sprintf(&str,"Wiedergabe ab Track #%02ld",CurrentTrack);
ShowInfoString(&str);
}
break;
}
}
break;
case MENUPICK:
if((MENUNUM(MCode))==0)
{
switch(ITEMNUM(MCode))
{
case 0:
SaveList();
break;
case 2:
EdEntry();
break;
}
}
break;
}
IMsg=GetMsg(UserPort);
}
}
}
CloseAll();
}
VOID OpenAll(name,num)
UBYTE *name;
UBYTE num;
{
register struct FileHandle *fh;
CDName=NULL;
IntuitionBase=OpenLibrary("intuition.library",0L);
GfxBase=OpenLibrary("graphics.library",0L);
ATUtilitiesBase=OpenLibrary("at-utilities.library",0L);
if((IntuitionBase==NULL)||(GfxBase==NULL)) CloseAll();
if(ATUtilitiesBase==NULL)
{
puts("Keine ATUtilities-Library!");
CloseAll();
}
DiskfontBase=OpenLibrary("diskfont.library",0L);
if(DiskfontBase==NULL) CloseAll();
DigitalFont=OpenDiskFont(&DigitalAttr);
if(DigitalFont==NULL)
{
InfoRequest("Kann hpcalc/18-Font nicht laden!");
CloseAll();
}
UtilityPort=FindPort(CDPlayerPort);
if(UtilityPort!=NULL)
{
InfoRequest("ATUtilities CDROM-Player ist schon aktiv.");
CloseAll();
}
MainTask=FindTask(NULL);
port=CreatePort("scsi-communications.port",0);
stop=CreatePort("cd-diskchange.port",0);
reply=CreatePort("cd-diskchange-reply.port",0);
if((port==NULL)||(stop==NULL)||(reply==NULL))
{
InfoRequest("Kein Speicher für Ports!");
CloseAll();
}
io=CreateExtIO(port,sizeof(struct IOExtTD));
if(io==NULL)
{
InfoRequest("Kein Speicher für SCSI-Request!");
CloseAll();
}
dev=OpenDevice(name,num,io,0);
if(dev!=0)
{
puts("Device läßt sich nicht öffnen!");
CloseAll();
}
buffer=AllocRemember(&Remember,2048,MEMF_CLEAR|MEMF_PUBLIC);
scsi=AllocRemember(&Remember,sizeof(struct SCSICmd),MEMF_CLEAR|MEMF_PUBLIC);
sense=AllocRemember(&Remember,18,MEMF_CLEAR|MEMF_PUBLIC);
catalog=AllocRemember(&Remember,sizeof(struct CDCatalog),MEMF_CLEAR|MEMF_PUBLIC);
tocheader=AllocRemember(&Remember,sizeof(struct TOCHeader),MEMF_CLEAR|MEMF_PUBLIC);
tocdata=AllocRemember(&Remember,sizeof(struct TOCData),MEMF_CLEAR|MEMF_PUBLIC);
msg=AllocRemember(&Remember,sizeof(struct Message),MEMF_CLEAR|MEMF_PUBLIC);
if((msg==NULL)||(buffer==NULL)||(sense==NULL)||(catalog==NULL)||(tocheader==NULL)||(tocdata==NULL))
{
InfoRequest("Nicht genug Speicher!");
CloseAll();
}
TimerSignal=AllocSignal(-1L);
if(TimerSignal<0)
{
InfoRequest("Keine freien Task-Signale!");
CloseAll();
}
TimerSignalMask=(1L<<TimerSignal);
SubTask=CreateProcess(TimerTask,500,"cd-diskchange.process",2);
if(SubTask==NULL)
{
InfoRequest("Kann Task nicht erstellen!");
CloseAll();
}
fh=Open(CDCatalogName,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,catalog,sizeof(struct CDCatalog));
Close(fh);
}
else
{
catalog->EntryCount=0;
}
UtilityPort=CreatePort(CDPlayerPort,0);
if(UtilityPort==NULL)
{
ErrorRequest(ERROR_MPORT);
CloseAll();
}
if((GetDriveInfo())==FALSE)
{
InfoRequest("Kann Laufwerksdaten nicht lesen!");
CloseAll();
}
PortSignal=UtilityPort->mp_SigBit;
PortSignalMask=(1L<<PortSignal);
WaitSignalMask=PortSignalMask+TimerSignalMask;
}
VOID CloseAll()
{
if(UtilityPort)
{
DeletePort(UtilityPort);
SCSI(&unlock,6,buffer,0,SCSIF_WRITE);
}
if(HCScreen!=NULL) HiFiControl();
if(SubTask)
{
msg->mn_Node.ln_Type=NT_MESSAGE;
msg->mn_ReplyPort=reply;
PutMsg(stop,msg);
WaitPort(reply);
Delay(20);
}
if(dev==0) CloseDevice(io);
if(io) DeleteExtIO(io);
if(port) DeletePort(port);
if(stop) DeletePort(stop);
if(reply) DeletePort(reply);
if(Remember) FreeRemember(&Remember,TRUE);
if(TimerSignal!=-1L) FreeSignal(TimerSignal);
if(DigitalFont) CloseFont(DigitalFont);
if(DiskfontBase) CloseLibrary(DiskfontBase);
if(ATUtilitiesBase) CloseLibrary(ATUtilitiesBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(GfxBase) CloseLibrary(GfxBase);
exit(0);
}
VOID TimerTask()
{
register struct Message *msg;
geta4();
msg=GetMsg(stop);
while(msg==NULL)
{
Signal(MainTask,TimerSignalMask);
if(play==TRUE)
Delay(45);
else
Delay(150);
msg=GetMsg(stop);
}
ReplyMsg(msg);
Exit(0);
}
/* Play-Symbol im Kontrolldisplay */
VOID PlaySymbol()
{
if((HCScreen!=NULL)&&(OldSymbol!=0))
{
DrawCPBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,22);
Draw(HCRPort,40,12);
OldSymbol=0;
}
}
/* Stop-Symbol im Kontrolldisplay */
VOID StopSymbol()
{
if((HCScreen!=NULL)&&(OldSymbol!=2))
{
DrawCPBorder(HCWindow,35,5,50,35);
SetAPen(HCRPort,3);
Move(HCRPort,40,12);
Draw(HCRPort,40,32);
Draw(HCRPort,80,32);
Draw(HCRPort,80,12);
Draw(HCRPort,40,12);
OldSymbol=2;
}
}
/* Titel im Kontrolldisplay */
VOID ShowInfoString(tex)
UBYTE *tex;
{
UBYTE str[50];
if(HCScreen!=NULL)
{
if(tex==NULL)
{
if(OldIS!=NULL)
{
sprintf(&str,"%s %s, %s",&Vendor,&Product,&Revision);
DrawCPBorder(HCWindow,290,5,340,16);
SetAPen(HCRPort,3);
WriteMText(HCRPort,300,16,320,&str);
OldIS=NULL;
}
}
else
{
DrawCPBorder(HCWindow,290,5,340,16);
SetAPen(HCRPort,3);
WriteMText(HCRPort,300,16,320,tex);
OldIS=0xFFFFFFFF;
}
}
}
/* Player im Kontrolldisplay */
VOID ShowCD()
{
if(CDName==OldCDName) return;
if(HCScreen!=NULL)
{
OldCDName=CDName;
DrawCPBorder(HCWindow,290,24,340,16);
SetAPen(HCRPort,3);
if(CDName==NULL)
{
WriteMText(HCRPort,300,35,320,"-- Keine CD eingelegt --");
SetFont(HCRPort,DigitalFont);
SetAPen(HCRPort,3);
WriteText(HCRPort,100,29,"-- --.--");
SetFont(HCRPort,GetOpalFont());
}
else if(CDName==1L)
{
WriteMText(HCRPort,300,35,320,"-- Eingelegte CD hat kein Audio-Format --");
SetFont(HCRPort,DigitalFont);
SetAPen(HCRPort,3);
WriteText(HCRPort,100,29,"00 --.--");
SetFont(HCRPort,GetOpalFont());
}
else
WriteMText(HCRPort,300,35,320,CDName);
}
}
/* Kontrolldisplay */
VOID HiFiControl()
{
UBYTE str[6];
REGISTER UWORD i,j;
if(HCScreen==NULL)
{
HCScreen=OpenScreen(&HCScreenDef);
if(HCScreen!=NULL)
{
HCWindowDef.Screen=HCScreen;
HCWindow=OpenWindow(&HCWindowDef);
if(HCWindow!=NULL)
{
OldCDName=OldIS=0xFFFFFFFF;
OldSymbol=-1;
HCWindow->BlockPen=2;
HCRPort=HCWindow->RPort;
SetFont(HCRPort,GetOpalFont());
MenuStrip=BuildMenuStrip(HCWindow,7,AUTOBACKPEN);
if(MenuStrip!=NULL)
{
for(i=0;i<2;i++)
{
for(j=1;j<21;j++)
{
sprintf(&str,"%02ld",i*20+j);
CreateBoolGadget(HCWindow,35+((j-1)*30),50+(i*15),25,12,&str,i*20+j);
}
}
if(elock==FALSE)
LockGadget=CreateNToggleGadget(HCWindow,35,80,25,12,"L",4096);
else
LockGadget=CreateSToggleGadget(HCWindow,35,80,25,12,"L",4096);
CreateBoolGadget(HCWindow,65,80,115,12,"Auswurf",10000);
CreateBoolGadget(HCWindow,185,80,325,12,"Stop",10001);
CreateBoolGadget(HCWindow,515,80,55,12,"-",10005);
CreateBoolGadget(HCWindow,575,80,55,12,"+",10006);
AddMenu(MenuStrip,"CD-Liste",5,120);
AddItem(MenuStrip,"Eintrag ändern",300,'A',TRUE,TRUE);
AddItem(MenuStrip,GetOpalLine(),300,0,FALSE,FALSE);
AddItem(MenuStrip,"Liste sichern",300,'S',TRUE,TRUE);
UseMenuStrip(MenuStrip);
DrawPBorder(HCWindow,90,5,190,35);
UserPort=HCWindow->UserPort;
IDCMPSignal=UserPort->mp_SigBit;
IDCMPSignalMask=(1L<<IDCMPSignal);
WaitSignalMask=PortSignalMask+IDCMPSignalMask+TimerSignalMask;
HCViewPort=ViewPortAddress(HCWindow);
LoadRGB4(HCViewPort,&Colors,8);
ShowCD();
ShowInfoString(NULL);
if(play) PlaySymbol(); else StopSymbol();
return;
}
}
}
}
if(HCWindow)
{
ClearMenuStrip(HCWindow);
CloseWindow(HCWindow);
}
if(MenuStrip) RemoveMenuStrip(MenuStrip);
if(HCScreen) CloseScreen(HCScreen);
WaitSignalMask=PortSignalMask+TimerSignalMask;
IDCMPSignalMask=0;
HCScreen=NULL;
HCWindow=NULL;
MenuStrip=NULL;
}
WORD SCSI(cmd,len,buf,buflen,direction)
UBYTE *cmd;
UBYTE *buf;
LONG buflen;
WORD len,direction;
{
io->io_Command=HD_SCSICMD;
io->io_Data=scsi;
io->io_Length=sizeof(struct SCSICmd);
scsi->scsi_Data=buf;
scsi->scsi_Length=buflen;
scsi->scsi_Flags=SCSIF_AUTOSENSE|direction;
scsi->scsi_SenseData=sense;
scsi->scsi_SenseLength=18;
scsi->scsi_SenseActual=0;
scsi->scsi_Command=cmd;
scsi->scsi_CmdLength=len;
cmd[1] |= LUN << 5;
DoIO(io);
return(scsi->scsi_Status);
}
BOOL GetDriveInfo()
{
struct DriveInfo *di;
status=SCSI(&driveinfo,6,buffer,sizeof(struct DriveInfo),SCSIF_READ);
if(status==0)
{
di=buffer;
strncpy(&Vendor,di->Vendor,8);
Vendor[9]=0x00;
strncpy(&Product,di->Product,16);
Product[16]=0x00;
strncpy(&Revision,di->Revision,4);
Revision[4]=0x00;
return(TRUE);
}
return(FALSE);
}
VOID CheckCD()
{
REGISTER UWORD i,j,k;
UBYTE str[50];
if((SCSI(&test,10,buffer,512,SCSIF_READ))==0)
{
if(HCScreen!=NULL)
{
SetFont(HCRPort,DigitalFont);
SetAPen(HCRPort,3);
sprintf(&str,"%02d %02d.%02d",(UWORD)tc[buffer[2]],(UWORD)tc[buffer[4]],(UWORD)tc[buffer[5]]);
WriteText(HCRPort,100,29,&str);
SetFont(HCRPort,GetOpalFont());
CurrentTrack=tc[buffer[2]];
}
if(buffer[0]==0x00)
{
PlaySymbol();
play=TRUE;
inserted=TRUE;
}
else
{
StopSymbol();
inserted=FALSE;
play=FALSE;
}
}
if((SCSI(&readtoc,10,buffer,TOC_SIZE,SCSIF_READ))==0)
{
inserted=TRUE;
CopyMem(buffer,tocheader,sizeof(struct TOCHeader));
CopyMem((ULONG)buffer+4L,tocdata,sizeof(struct TOCData));
FirstTrack=tocheader->FirstTrack;
LastTrack=tocheader->LastTrack;
j=0; k=0xFFFF;
for(i=0;i<tocheader->Length/8;i++)
{
if((tocdata->TrackNumber!=0xAA) && !(tocdata->Flags & 4))
{
TrackAddress[j]=tocdata->Address;
j++;
if(k==0xFFFF) k=tocdata->TrackNumber;
}
}
TrackCount=j;
if(j!=0)
{
FindCD();
CDName=&catalog->Entry[cdpos].Name;
ShowCD();
}
else
{
ShowInfoString("Bitte legen Sie eine Audio-CD ein!");
CDName=1L;
ShowCD();
}
}
else
{
StopSymbol();
ShowInfoString(NULL);
CDName=NULL;
ShowCD();
inserted=FALSE;
play=FALSE;
}
}
VOID FindCD()
{
REGISTER UWORD i,j,k;
REGISTER BOOL found;
found=FALSE;
for(i=0;i<catalog->EntryCount;i++)
{
if(catalog->Entry[i].TitleCount==TrackCount)
{
k=0;
for(j=0;j<catalog->Entry[i].TitleCount;j++)
{
if(catalog->Entry[i].Address[j]==TrackAddress[j]) k++;
}
if(k==catalog->Entry[i].TitleCount)
{
cdpos=i;
found=TRUE;
goto cd_found;
}
}
}
cd_found:
if(found==FALSE)
{
cdpos=catalog->EntryCount;
catalog->Entry[cdpos].TitleCount=TrackCount;
strcpy(&catalog->Entry[cdpos].Name,"Unbekannte CD - Wählen Sie \"Eintrag ändern\" im Menü!");
for(i=0;i<TrackCount;i++)
{
catalog->Entry[cdpos].Address[i]=TrackAddress[i];
}
catalog->EntryCount++;
}
}
VOID EdEntry()
{
REGISTER BOOL bool;
REGISTER UBYTE *name;
register struct Window *win;
if(inserted==FALSE) return;
win=CreateWindow(HCScreen,0L,
88,2,544,40,
GADGETUP|VANILLAKEY,
BORDERLESS|ACTIVATE);
if(win!=NULL)
{
SetFont(win->RPort,GetOpalFont());
SetAPen(win->RPort,3);
WriteText(win->RPort,15,15,"Titel der aktuellen CD:");
CreateBoolGadget(win,492,24,50,12,"Okay",10);
name=CreateStringGadget(win,3,24,480,12,&catalog->Entry[cdpos].Name,58,20);
bool=FALSE;
while(bool==FALSE)
{
WaitPort(win->UserPort);
IMsg=GetMsg(win->UserPort);
if(IMsg->Class==GADGETUP) bool=TRUE;
if(IMsg->Code==13) bool=TRUE;
ReplyMsg(IMsg);
}
strcpy(&catalog->Entry[cdpos].Name,name);
CDName=name;
DeleteStdWindow(win);
ShowCD();
}
}
VOID SaveList()
{
register struct FileHandle *fh;
if(catalog->EntryCount>0)
{
fh=Open(CDCatalogName,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,catalog,catalog->EntryCount*sizeof(struct CDCatalogEntry));
Close(fh);
}
}
}